package com.tj.jinzao.fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.tj.jinzao.R;
import com.tj.jinzao.activity.CompleteInfoActivity;
import com.tj.jinzao.base.BaseFragment;
import com.tj.jinzao.utils.ToastUtils;
import com.tj.jinzao.widgets.HorizontalScaleView;

import butterknife.BindView;
import butterknife.OnClick;


/**
 * 完善资料4-身高
 * Created by wjy on 2019/1/6.
 */
public class CompleteInfoStep4Fragment extends BaseFragment {

    @BindView(R.id.scale_view)
    HorizontalScaleView mScaleView;
    @BindView(R.id.tv_height)
    TextView mHeightView;

    private int mHeight = 175;

    @Override
    protected void setupViews(LayoutInflater inflater, View view) {
        super.setupViews(inflater, view);
        mScaleView.setRange(100, 250);
        mScaleView.setOnValueChangeListener(new HorizontalScaleView.OnValueChangeListener() {
            @Override
            public void onValueChanged(float value) {
                mHeight = (int) value;
                mHeightView.setText(String.valueOf((int) value) + "cm");
            }
        });
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.fragment_complete_info_step_4;
    }

    @OnClick(R.id.bt_next)
    public void next() {
        if (mContext instanceof CompleteInfoActivity) {
            if(mHeight != 0){
                ((CompleteInfoActivity) mContext).setData("height",mHeight);
            }else {
                ToastUtils.showToast(getActivity(),"请选择身高");
                return;
            }
            ((CompleteInfoActivity) mContext).next();
        }
    }

}
